/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2011 All Rights Reserved.
 */
package com.alipay.supergw.common.dal.share_supergw.auto.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.alipay.supergw.common.dal.share_supergw.auto.daointerface.ChannelSystemDAO;
import com.alipay.supergw.common.dal.share_supergw.auto.dataobject.ChannelSystemDO;

/**
 * An ibatis based implementation of dao interface <tt>com.alipay.supergw.common.dal.share_supergw.auto.daointerface.ChannelSystemDAO</tt>.
 *
 * This file is generated by <tt>supergw-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>supergw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/sgw_channel_system.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>supergw-dalgen</tt> 
 * to generate this file.
 */
public class IbatisChannelSystemDAO extends SqlMapClientDaoSupport implements ChannelSystemDAO {

    /**
     *  Query DB table <tt>sgw_channel_system</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select channel_system_id, channel_system_name, memo, type, gmt_create, gmt_modified from sgw_channel_system</tt>
     *
     *	@return List<ChannelSystemDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings("unchecked")
    public List<ChannelSystemDO> loadAll() throws DataAccessException {

        return getSqlMapClientTemplate().queryForList("MS-CHANNEL-SYSTEM-LOAD-ALL", null);

    }

    /**
     *  Insert one <tt>ChannelSystemDO</tt> object to DB table <tt>sgw_channel_system</tt>, return primary key
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>insert into sgw_channel_system(channel_system_id,channel_system_name,memo,type,gmt_create,gmt_modified) values (?, ?, ?, ?, sysdate, sysdate)</tt>
     *
     *	@param channelSystem
     *	@return String
     *	@throws DataAccessException
     */
    public String insert(ChannelSystemDO channelSystem) throws DataAccessException {
        if (channelSystem == null) {
            throw new IllegalArgumentException("Can't insert a null data object into db.");
        }

        getSqlMapClientTemplate().insert("MS-CHANNEL-SYSTEM-INSERT", channelSystem);

        return channelSystem.getChannelSystemId();
    }

    /**
     *  Query DB table <tt>sgw_channel_system</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select channel_system_id, channel_system_name, memo, type, gmt_create, gmt_modified from sgw_channel_system where (channel_system_id = ?)</tt>
     *
     *	@param channelSystemId
     *	@return ChannelSystemDO
     *	@throws DataAccessException
     */
    public ChannelSystemDO select(String channelSystemId) throws DataAccessException {

        return (ChannelSystemDO) getSqlMapClientTemplate().queryForObject(
            "MS-CHANNEL-SYSTEM-SELECT", channelSystemId);

    }

    /**
     *  Update DB table <tt>sgw_channel_system</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>update sgw_channel_system set channel_system_name=?, type=?, memo=?, gmt_modified=sysdate where (channel_system_id = ?)</tt>
     *
     *	@param channelSystemName
     *	@param type
     *	@param memo
     *	@param channelSystemId
     *  @param parentChannelSystemId
     *	@return int
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public int update(String channelSystemName, String parentChannelSystemId, String type,
                      String memo, String channelSystemId) throws DataAccessException {
        Map param = new HashMap();
        param.put("parentChannelSystemId", parentChannelSystemId);
        param.put("channelSystemName", channelSystemName);
        param.put("type", type);
        param.put("memo", memo);
        param.put("channelSystemId", channelSystemId);

        return getSqlMapClientTemplate().update("MS-CHANNEL-SYSTEM-UPDATE", param);
    }

    /**
     *  Delete records from DB table <tt>sgw_channel_system</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>delete from sgw_channel_system where (channel_system_id = ?)</tt>
     *
     *	@param channelSystemId
     *	@return int
     *	@throws DataAccessException
     */
    public int delete(String channelSystemId) throws DataAccessException {

        return getSqlMapClientTemplate().delete("MS-CHANNEL-SYSTEM-DELETE", channelSystemId);
    }

}